package com.iamteer.d_fileupload;

import java.io.File;

import org.apache.commons.io.FileUtils;

import com.opensymphony.xwork2.ActionSupport;

public class FileUploadAction extends ActionSupport {
	// 文件，对应文件表单：文件：<input type="file" name="file1">
	private File file1;
	// 文件名
	private String file1FileName;
	// 文件类型（MIME）
	private String file1ContentType;
	
	public void setFile1(File file1) {
		this.file1 = file1;
	}
	public void setFile1FileName(String file1FileName) {
		this.file1FileName = file1FileName;
	}
	public void setFile1ContentType(String file1ContentType) {
		this.file1ContentType = file1ContentType;
	}
	
	@Override
	public String execute() throws Exception {
		System.out.println("file upload...");
		
		String path = "/Volumes/ChuckHD/Temp";	//临时目录
		
		File file = new File(path, file1FileName);
		
		FileUtils.copyFile(file1, file);
		
		return SUCCESS;
	}
}
